<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html>
<html lang="zh">
<head>
<base href="${APP_PATH}/">
<meta charset="utf-8">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>教学管理系统</title>
<link rel="icon" href="public/favicon.ico" type="image/ico">
<meta name="keywords" content="LightYear,光年,后台模板,后台管理系统,光年HTML模板">
<meta name="description"
	content="LightYear是一个基于Bootstrap v3.3.7的后台管理系统的HTML模板。">
<meta name="author" content="yinqi">
<jsp:include page="/commons.jsp"></jsp:include>
</head>

<body>
	<div class="lyear-layout-web">
		<div class="lyear-layout-container">
			<!--左侧导航-->
			<%@ include file="/menu.jsp"%>
			<!--End 左侧导航-->

			<!--头部信息-->
			<%@ include file="/head.jsp"%>
			<!--End 头部信息-->

			<!--页面主要内容-->
			<main class="lyear-layout-content">

				<div class="container-fluid">

					<div class="row">
						<div class="col-lg-12">
							<div class="card">
								<div class="card-toolbar clearfix">
									<form class="pull-right search-bar" method="get" 
										role="form">
										<div class="input-group">
											<div class="input-group-btn">
												<input type="hidden" name="uid" id="uid"
													value="${loginUser.uid}">
												

											</div>
										<input type="text" class="form-control" value=""
												name="rnameLike" id="rnameLike" placeholder="请输入名称">

										</div>

									</form>
										
								</div>
								<div class="card-body">
        
									<div class="table-responsive">
									     <form id="delForm">
										<table class="table table-bordered">
											<thead>
												<tr>
													<th><label class="lyear-checkbox checkbox-primary">
															<input type="checkbox" id="check-all"><span></span>
													</label></th>
													<th>序号</th>
													<th>班级名称</th>
													<th>教师</th>
													<th>班主任</th>
													<th>科目</th>
													<th>教室</th>

												</tr>
											</thead>
											<tbody id="classList">



											</tbody>
											</form>
											<tfoot>
												<tr>
													<td colspan="7" align="center">
														<ul class="pagination" id="byPage" id="byPage">
															<li class="disabled"><a href="#">上一页</a></li>
															<li class="active"><a href="#">1 <span
																	class="sr-only">(current)</span></a></li>
															<li><a href="#">2</a></li>
															<li><a href="#">3</a></li>
															<li><a href="#">4</a></li>
															<li><a href="#">5</a></li>
															<li><a href="#">下一页</a></li>
														</ul>
													</td>
												</tr>

											</tfoot>
										</table>
										
									</div>
									<ul class="pagination" id="pageList">



									</ul>

								</div>
							</div>
						</div>

					</div>

				</div>

			</main>
			<!--End 页面主要内容-->
		</div>
	</div>


	<script type="text/javascript">
   $(function(){
       layer.msg("加载中", {time:500, icon:16, shift:5}, function(){
          /*  goPage(1,""); */
       });//layer 
       showByPage();

       })
       
      
       
   //入口
       function showByPage(){

	          var uid=$("#uid").val();
	            $.ajax({
	            	url:"${APP_PATH}/class/teacherIndexDo",
	            	type:"post",
	            	data:{"uid":2},
	            	success:function(data){
	            		var tbodyContent="";
	            		
	            	       $.each(data.classList,function(index,obj){
	            	    	 console.log(obj);
	            	    	 tbodyContent+="<tr>";
	  	        			 tbodyContent+="<th><input type='checkbox' name='cid' value='"+obj.cid+"'></th>"
	  	        			 tbodyContent+="<th>"+(index+1)+"</th>";
	  	        			 tbodyContent+="<th>"+obj.cname+"</th>";
	  	        			 tbodyContent+="<th>"+obj.teacher.uname+"</th>";
	  	        			 tbodyContent+="<th>"+obj.classmanager.uname+"</th>";
	  	        			 tbodyContent+="<th>"+obj.course.cname+"</th>";
	  	        			 tbodyContent+="<th>"+obj.room.rname+"</th>";      
	            	       });
	            	     $("#classList").html(tbodyContent);
	            	     
	  	        		 var pageMessage="";
	  	        		 pageMessage+='<li class="'+(data.pageInfo.pageNum==1?"disabled":"")+'"><a onclick="show('+data.pageInfo.perPage+')">上一页</a></li>';
	  		    	     for(var i=1;i<=data.pageInfo.pages;i++){
	  		    	    	 pageMessage+='<li class="'+(data.pageInfo.pageNum==i?"active":"")+'"><a onclick="show('+i+')">'+i+'<span class="sr-only">(current)</span></a></li>';
	  		    	     }
	  		    	     pageMessage+='<li class="'+(data.pageInfo.pageNum==data.pageInfo.pages?"disabled":"")+'"><a onclick="show('+data.pageInfo.nextPage+')">下一页</a></li>';
	  		    	      $("#byPage").html(pageMessage);
	            	},
	            })
	        
	        
	         $("#btnAdd").click(function(){
    	      
    	      window.location.href="${APP_PATH}/class/add"; 
    	      
       });
	        $("#btnDel").click(function(){
	        	var select=window.confirm("是否确认删除已选择的");
	        	        $.ajax({
	        	        url:"${APP_PATH}/class/deleteDo",
	        	        type:"post",
	        	        data:$("#delForm").serialize(),
	        	        success:function(data){
	        	        	 if(data.msg){
	        	        		 layer.msg("删除成功",{time:2000,icon:6,shift:4},function(){
               	    				window.location.href="${APP_PATH}/class/teacherIndexDo";
               	    			})
	        	        	 }else{
	        	        		 layer.msg("删除失败",{time:2000,icon:5,shift:4},function(){
	               	    			  
	               	    			})
	        	        	 }
	        	        }
	        	     })
	        })
   }
   
</script>
</body>
</html>
